<template>
    <div class="top-menu">
        <header class="top">
            <div style="width: 35%; float: left; padding: 10px;font-size:14px">
                <!-- <div style="display:inline-block">
                    <img :src="getOrgLogo()" alt="">
                </div> -->
                <span @click="doRouter('/wel/index',0)" class="go-back" :class="{'active':globalMenuIndex == 0}" v-hasMenu="['rule:index']">首页</span>
                <span @click="doRouter('/business/main',1)" class="go-back" :class="{'active':globalMenuIndex == 1}" v-hasMenu="['rule:info']">信息管理</span>
                <span @click="doRouter('/alarm',2)" class="go-back" :class="{'active':globalMenuIndex == 2}" v-hasMenu="['rule:alarm']">告警管理</span>
                <span @click="doRouter('/report',3)" class="go-back" :class="{'active':globalMenuIndex == 3}" v-hasMenu="['rule:report']">数据报表</span>
                <span @click="doRouter('/admin/index',4)" class="go-back" :class="{'active':globalMenuIndex == 4}" v-hasMenu="['rule:admin']">基础配置</span>
            </div>
            <div class="header_center">中晟创通电动车风险监测平台</div>
            <div class="header_full">
                <org-select v-hasOrg v-model="orgId" @select="query" default-value></org-select>
                <div v-if="userInfo.orgId !== '-1'" style="color:#fff">
                    {{userInfo.orgName}}
                </div>
                <el-dropdown style="cursor: pointer;color:#fff;font-size:30px;display: flex;margin-left:20px">
                    <span class="el-dropdown-link">
                        {{ userInfo.staffName||userInfo.username }}
                        <i class="el-icon-arrow-down el-icon--right"></i>
                    </span>
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item>
                            <router-link to="/">首页</router-link>
                        </el-dropdown-item>
                        <el-dropdown-item>
                            <router-link to="/info/index">个人信息</router-link>
                        </el-dropdown-item>
                        <el-dropdown-item @click.native="logout" divided>退出系统</el-dropdown-item>
                    </el-dropdown-menu>
                </el-dropdown>
            </div>
        </header>
    </div>
</template>
<script>
import { mapGetters, mapState } from 'vuex'
export default {
    name: 'top',
    data() {
        return {
            orgId: -1
            // activeIndex: 0
        }
    },
    computed: {
        ...mapGetters(['website']),
        ...mapGetters(['userInfo', 'tagWel', 'tagList', 'isCollapse', 'tag','orgLogo']),
        ...mapState('data', ['globalMenuIndex'])
    },
    mounted() {
        this.$store.dispatch('GetMenu', { type: true, id: -1 }).then(data => {
            // if (data.length === 0) return;
            this.$router.$avueRouter.formatRoutes(data, true)
        })
    },
    methods: {
        logout() {
            this.$confirm('是否退出系统, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$store.dispatch('LogOut').then(() => {
                    this.$store.dispatch('data/setGlobalMenuIndex', 0)
                    this.$router.push({ path: '/login' })
                })
            })
        },
        getOrgLogo(){
            return this._buillStaticPath(this.orgLogo)
        },
        doRouter(path, index) {
            // this.activeIndex = index
            this.$store.dispatch('data/setGlobalMenuIndex', index)
            this.$router.push({ path: path })
        },
        query(data) {
            this.$store.dispatch('data/setGlobalOrg', data)
            this.$root.Bus.$emit('change-global-orgid')
        }
    }
}
</script>

<style scoped lang="scss">
/deep/.el-input__inner {
    background-color: #034c6a;
    color: #fff;
    border: none;
}
.top-menu {
    display: flex;
    flex-direction: column;
    background-color: #081832;
    transition: all ease-in-out;
    position: relative;
    .bottom {
        border-left: 1px solid #e0e0e0;
        flex: 2;
        border-top: 1px solid #e0e0e0;
    }
    .top {
        margin-left: 1px;
        position: relative;
        height: 70px;
        .header_center {
            width: 30%;
            background-image: url(/img/logoBg.png);
            background-size: 100% 100%;
            color: #a4c2ce;
            text-align: center;
            line-height: 60px;
            font-size: 20px;
            float: left;
        }
        .go-back {
            color: #adcedc;
            padding: 10px 5px;
            font-size: 16px;
            cursor: pointer;
            width: 80px;
            display: inline-block;
            text-align: center;
            margin-right:2px;
        }
        .go-back.active {
            border-bottom: 4px solid #4b8df8;
            box-shadow: -10px 0px 15px #034c6a inset, 0px -10px 15px #034c6a inset, 10px 0px 15px #034c6a inset, 0px 10px 15px #034c6a inset;
            box-sizing: border-box;
        }
        .go-back:hover {
            border-bottom: 4px solid #4b8df8;
            box-shadow: -10px 0px 15px #034c6a inset, 0px -10px 15px #034c6a inset, 10px 0px 15px #034c6a inset, 0px 10px 15px #034c6a inset;
            box-sizing: border-box;
        }
    }
    .header_full {
        color: #034c6a;
        font-size: 20px;
        cursor: pointer;
        width: 33%;
        text-align: right;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        height: 70px;
    }
    .header_full:hover {
        color: #fff;
    }
    .title {
        background-color: #034c6a;
        border-radius: 5px;
        position: absolute;
        height: 35px;
        width: 60%;
        top: -15px;
        color: #ffffff;
        font-weight: bold;
        font-size: 16px;
        left: 20%;
        line-height: 35px;
        text-align: center;
        z-index: 1;
    }
    .warning {
        animation: glow 800ms ease-out infinite alternate;
    }
    .container {
        flex: 1;
        .left {
            width: 24%;
            margin-left: 1%;
            float: left;
            height: 95%;
            &-card {
                box-shadow: -10px 0px 15px #034c6a inset, 0px -10px 15px #034c6a inset, 10px 0px 15px #034c6a inset, 0px 10px 15px #034c6a inset;
                border: 1px solid #034c6a;
                box-sizing: border-box;
                position: relative;
                margin-top: 25px;
                height: 48%;
            }
        }
        .center {
            width: 48%;
            margin-right: 1%;
            margin-left: 1%;
            float: left;
            height: 95%;
            box-shadow: -10px 0px 15px #034c6a inset;
            border: 1px solid #034c6a;
            box-sizing: border-box;
            position: relative;
            margin-top: 25px;
            padding: 7px;
        }
        .right {
            width: 24%;
            margin-right: 1%;
            float: right;
            height: 95%;
            &-card {
                height: 48%;
                box-shadow: -10px 0px 15px #034c6a inset, 0px -10px 15px #034c6a inset, 10px 0px 15px #034c6a inset, 0px 10px 15px #034c6a inset;
                border: 1px solid #034c6a;
                box-sizing: border-box;
                position: relative;
                margin-top: 25px;
                padding: 25px;
                display: flex;
                flex-direction: column;
            }
            .user-info {
                color: #fff;
                list-style: none;
            }
        }
    }
}
@keyframes glow {
    0% {
        border-color: #ec8585;
        box-shadow: 0 0 5px rgba(0, 255, 0, 0.2), inset 0 0 5px rgba(0, 255, 0, 0.1), 0 1px 0 #ec8585;
    }
    100% {
        border-color: #ff0000;
        box-shadow: 0 0 40px rgba(249, 0, 0, 0.6), inset 0 5px 20px rgba(249, 2, 2, 0.4), 0 1px 0 #ff0000;
    }
}
.full-screen {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 1111;
    transform: scale(1);
}
</style>
